﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="quanlydiem.aspx.cs" Inherits="webtracuudiem.quanlydiem" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .auto-style1 {
            width: 100%;
        }
        .auto-style2 {
            font-size: x-large;
            color: #FF3300;
            text-align: center;
            background-color: #FF9933;
        }
       
        .auto-style3 {
            width: 26px;
            height: 27px;
        }
        .auto-style4 {
            text-decoration: none;
        }
        .auto-style5 {
            background-color: #66FF33;
        }
        .auto-style6 {
            height: 21px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="auto-style1">
        <tr>
            <td class="auto-style2" colspan="4"><strong id="labQUANLYDIEM">QUẢN LÝ ĐIỂM</strong></td>
            <td>
                <asp:Button ID="ButThoat" runat="server" Text="Đăng xuất" Width="97px" OnClick="ButThoat_Click" />
            </td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td colspan="2">&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td colspan="2" class="auto-style6">Tên Ngành</td>
            <td class="auto-style6">Lớp</td>
            <td class="auto-style6">Môn</td>
            <td class="auto-style6"></td>
            <td class="auto-style6"></td>
        </tr>
        <tr>
            <td id="labTennganh" colspan="2">
                <asp:DropDownList ID="DropTenNganh" runat="server" Height="25px" style="margin-left: 5px" Width="150px" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="TenNganh" DataValueField="MaNganh">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Demo1ConnectionString %>" SelectCommand="SELECT * FROM [NganhHoc]"></asp:SqlDataSource>
            </td>
            <td id="labLop">
                <asp:DropDownList ID="DropLop" runat="server" Height="25px" style="margin-left: 5px" Width="100px" DataSourceID="SqlDataSource2" DataTextField="MaLop" DataValueField="MaLop">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Demo1ConnectionString %>" SelectCommand="select *
from Lop where MaNganh=@manganh">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropTenNganh" Name="manganh" PropertyName="SelectedValue" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
            <td id="labMon">
                <asp:DropDownList ID="DropMon" runat="server" Height="25px" style="margin-left: 5px" Width="200px" DataSourceID="SqlDataSource3" DataTextField="TenMH" DataValueField="MaMH">
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:Demo1ConnectionString %>" SelectCommand="select MonHoc.MaMH,tenmh
from MonHocCuaNganh,MonHoc where MonHocCuaNganh.MaMH=MonHoc.MaMH  and MaNganh=@manganh ">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropTenNganh" Name="manganh" PropertyName="SelectedValue" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
            <td>
                <asp:Button ID="ButHienthi" runat="server" Text="Hiển thị" Width="97px" OnClick="ButHienthi_Click" />
                </td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td class="auto-style6" colspan="4">
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="MaSV" DataSourceID="nhapdiemSource">
                    <Columns>
                        <asp:BoundField HeaderText="MaSV" DataField="MaSV" ReadOnly="True" SortExpression="MaSV" />
                        <asp:BoundField HeaderText="HoLot" DataField="HoLot" SortExpression="HoLot" />
                        <asp:BoundField HeaderText="Ten" DataField="Ten" SortExpression="Ten" />
                        <asp:TemplateField HeaderText="DiemL1" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:TextBox ID="txtDiemL1" runat="server" Width="35px" Text='<%#Eval("DiemL1") %>'  />
                                <asp:CompareValidator runat="server" ControlToValidate="txtDiemL1" Operator="DataTypeCheck" Type="Double" ErrorMessage="*" />
                                <asp:RangeValidator runat="server" ControlToValidate="txtDiemL1"  MaximumValue="10" MinimumValue="0" Type="Double" ErrorMessage="?"/>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="DiemL2" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:TextBox ID="txtDiemL2" runat="server" Width="35px" Text='<%#Eval("DiemL2") %>'/>
                                <asp:CompareValidator runat="server" ControlToValidate="txtDiemL2" Operator="DataTypeCheck" Type="Double" ErrorMessage="*" />
                                <asp:RangeValidator runat="server" ControlToValidate="txtDiemL2"  MaximumValue="10" MinimumValue="0" Type="Double" ErrorMessage="?"/>

                                <asp:HiddenField ID="hidenMaSV" runat="server" Value ='<%#Eval("MaSV") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="DiemKQ" DataField="DiemKQ" ReadOnly="True"/>
                    </Columns>
                </asp:GridView>
                </td>
            <td class="auto-style6"></td>
            <td class="auto-style6"></td>
        </tr>
        <tr>
            <td colspan="4" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<asp:SqlDataSource ID="nhapdiemSource" runat="server" ConnectionString="<%$ ConnectionStrings:Demo1ConnectionString %>"
                    SelectCommand="(SELECT  sv.MaSV,HoLot,Ten, DiemL1=NULL,DiemL2=NULL,DiemKQ=NULL
	FROM SinhVien sv 
	WHERE sv.MaLop=@MaLop  
			AND NOT EXISTS(
					SELECT sv.MaSV,HoLot,Ten,DiemL1,DiemL2,DiemKQ
					FROM Diem d,SinhVien sv 
					WHERE d.MaSV=sv.MaSV AND d.MaMH= @MaMH AND sv.MaLop=@MaLop
				)
)
UNION
(SELECT sv.MaSV,HoLot,Ten,DiemL1,DiemL2 ,DiemKQ
	FROM Diem d,SinhVien sv 
	WHERE d.MaSV=sv.MaSV AND d.MaMH= @MaMH AND sv.MaLop=@MaLop
	)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropLop" Name="MALOP" PropertyName="SelectedValue" />
                         <asp:ControlParameter ControlID="DropMon" Name="MAMH" PropertyName="SelectedValue" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
        <tr>
            <td >&nbsp;</td>
            <td >&nbsp;</td>
            <td>&nbsp;</td>
            <td>
                <asp:Button ID="ButCapnhat" runat="server" Text="Cập Nhật" Width="100px" OnClick="ButCapnhat_Click" />
            </td>
            <td>
                <span><a href="TrangPhongDaoTao.aspx" class="auto-style4"><img alt="" src="images/Arrow_back.png" class="auto-style3" /><span class="auto-style9"> <span class="auto-style5">BACK</span></span></a></span></td>
            <td>&nbsp;</td>
        </tr>
    </table>
</asp:Content>
